home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
090
/
pctj0687.arc
/
ASKKEY.ASM
< prev
next >
Wrap
Assembly Source File
|
1987-04-21
|
2KB
|
33 lines
; ASKKEY - Display text and accept a char from Standard Input.
; Return the ASCII code of the char as an ERRORLEVEL.
Code Segment
Org 0100H
Assume CS:Code, DS:Code
AskKey Proc Far
Begin: Mov SI,81H ; SI -> 1st cmd line char
; Display all text in the command line up to 0DH (Carridge Return)
NxtChar: Mov DL,[SI] ; get char from command line
Cmp DL,0DH ; CR char means end of string
Je GetChar ; Goto input mode if at end
Mov AH,02H ; Standard Output function
Int 21H ; call DOS to output char
Inc SI ; increment to next char
Jmp NxtChar ; and go get it
; Accept a single character response from Standard Input
GetChar: Mov AH,01H ; Standard Input function
Int 21H ; Call DOS, get char into AL
Cmp AL,0 ; extended character?
Je GetChar ; Yes, get the scan code
Cmp AL,'a' ; is char less than 'a' ?
Jb Xit ; Yes, skip case change
Cmp AL,'z' ; is it greater than 'z' ?
Ja Xit ; Yes, bypass case change
And AL,NOT 20H ; change to upper case
; Return to DOS with the RETCODE set
Xit: Mov AH,4CH ; Set exit function
Int 21H ; call DOS to leave
; AL already has RETCODE
AskKey Endp
Code Ends
End Begin